<template>
  <a-card
    class="general-card"
    :title="$t('workplace.announcement')"
    :header-style="{ paddingBottom: '0' }"
    :body-style="{ padding: '15px 20px 13px 20px' }"
  >
    <template #extra>
      <a-link>查看更多</a-link>
    </template>
    <div>
      <div v-for="(item, idx) in noticeList" :key="idx" class="item">
        <div class="notice-item">
          <a-card>
            <div class="notice-title">
              {{ item.title }}
            </div>
            <div class="notice-content">
              {{ item.content }}
            </div>
          </a-card>
        </div>
      </div>
    </div>
  </a-card>
</template>

<script lang="ts" setup>
  import axios from "axios";
  import { onMounted, ref } from "vue";

  const noticeList = ref([] as any)
  const onMountedNoticeList = () => {
    noticeList.value = []
    axios.get(`${import.meta.env.VITE_API_Admin_URL}bulletin/list`).then(res => {
      console.log(res)
      res.records.forEach((element:any) => {
        noticeList.value.push(element)
      });
    })
  }
  onMounted(async() => {
    await onMountedNoticeList()
  })

    
</script>

<style scoped lang="less">
  .item {
    display: flex;
    align-items: center;
    width: 100%;
    margin-bottom: 4px;
    .item-content {
      flex: 1;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      margin-left: 4px;
      color: var(--color-text-2);
      text-decoration: none;
      font-size: 13px;
      cursor: pointer;
    }
  }
  .notice-item {
    width: 100%;
    .notice-title {
      font-weight: bold;
      margin-bottom: 10px;
    }
  }
</style>
